package kks;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import kks.test.RobotTestBed;
import robocode.control.BattlefieldSpecification;

/**
 * Verifies that the CounterAll's gun uses less power when shooting at an enemy far away. Test case
 * structures modeled after David Mau's TestFiringStrategy.
 * 
 * @author Kelli Sawai
 * 
 */
public class TestFirePower extends RobotTestBed {

  BattlefieldSpecification field = new BattlefieldSpecification();
  // Height of the battlefield
  double fieldHeight = field.getHeight();
  // Width of the battlefield
  double fieldWidth = field.getWidth();

  /**
   * Specifies that SpinBot and CounterAll are to be matched up in this test case.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.SpinBot,kks.CounterAll";
  }

  /**
   * This test runs for 10 rounds.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * Checks to see if CounterAll fires at a lower power when the enemy is far away.
   * 
   */
  @Test
  public void testLongDistances() {
    CounterAll robot = new CounterAll();
    double max = Math.max(fieldHeight, fieldWidth);
    assertEquals("Checks fire power for long distances", robot.calculateFirePower(300, 90), 1);
    assertEquals("Checks fire power for long distances", robot.calculateFirePower(10000000, 45), 1);
    assertEquals("Checks fire power for long distances", robot.calculateFirePower(max, 70), 1);
  }

  /**
   * Checks to see if CounterAll fires at a high power when the enemy is closer or directly in
   * front.
   * 
   */
  @Test
  public void testOtherDistances() {
    CounterAll robot = new CounterAll();
    assertEquals("Checks fire power for short distances", robot.calculateFirePower(0, 0), 3);
    assertEquals("Checks fire power for parallel distances", robot.calculateFirePower(30, 0), 3);
    assertEquals("Checks fire power for parallel distances", robot.calculateFirePower(30, 180), 3);
  }

}
